package com.pkx.cloud.fse7.dms.tcm.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pkx.cloud.fse7.dms.tcm.entity.Tcm;
import com.pkx.cloud.fse7.dms.tcm.service.TcmService;
import com.pkx.cloud.whzx.comn.ORpose;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;

/**
 *  控制器
 *
 * @author chenwg
 * @since 2020-11-12
 */
@RestController
@RequestMapping("/dms.tcm/tcm")
@Api(value = "", tags = "")
@Slf4j
@ORpose
public class TcmController {

    @Autowired
    private TcmService tcmService;

    @ApiOperation("分页列表")
    @GetMapping("/page")
    public Page<Tcm> page(Page page, Tcm tcm) {
        return tcmService.pageList(page,tcm);
    }

    @ApiOperation("列表")
    @GetMapping("/list")
    public List<Tcm> list(Tcm tcm) {
        return tcmService.listByEntity(tcm);
    }

    @ApiOperation("详情")
    @GetMapping(value = "/{id}")
    public Tcm selectById(@PathVariable("id") Long id) {
        return tcmService.selectById(id);
    }

    @ApiOperation("新增")
    @PostMapping("/")
    public Boolean add(@RequestBody Tcm tcm) {
        return tcmService.saveTcm(tcm);
    }

    @ApiOperation("修改")
    @PutMapping("/")
    public Boolean modify(@RequestBody Tcm tcm) {
        return tcmService.modify(tcm);
    }

    @ApiOperation("删除(单个条目)")
    @DeleteMapping(value = "/{id}")
    public Boolean deleteById(@PathVariable("id") Long id) {
        return tcmService.deleteById(id);
    }
}
